package com.ctgu.service;

import com.ctgu.dao.UserMapper;
import com.ctgu.entity.User;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class UserServiceImpl implements UserService{

    @Autowired
    private UserMapper userMapper;

    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public boolean login(@org.jetbrains.annotations.NotNull User user) {
        User users = userMapper.findUser(user.getNickname(),user.getPassword());
        return users != null;
    }

    @Override
    public Integer addUser(User user){
        return userMapper.addUser(user);
    }

    @Override
    public Integer deleteUserById(Integer id){
        return userMapper.deleteUserById(id);
    }

    @Override
    public Integer updateUser(User user){
        return userMapper.updateUser(user);
    }

    @Override
    public List<User> getAllUserList(){
        return userMapper.getAllUserList();
    }

    @Override
    public User getUser(Integer id) {
        return userMapper.getUser(id);
    }

    @Override
    public List<User> queryUserByName(String username) {
        return userMapper.queryUserByName(username);
    }


    @Override
    public List<User> getUserListByLimit(Integer page, Integer limit){
        List<User> list = userMapper.getUserListByLimit(page, limit);
        return list;
    }

    @Override
    public Integer getUserCount(){
        int count = userMapper.getUserCount();
        return count;
    }
}
